package io.peng.j2se.lab;

/**
 * Created by eric on 16/3/15.
 */
public class Producer implements Runnable {
    public void run() {
        System.out.println("Producer is started");
        while (true) {
            if (MySingleton.getInstance().getBalance() <= 10) {
                MySingleton.getInstance().setBalance(MySingleton.getInstance().getBalance() + 1);
                System.out.println("Producer add 1, balance: "+ MySingleton.getInstance().getBalance());
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
